package pl.PawelAndAlicja.badugiproject.main.Players;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class ClientPlayer {

    public ClientPlayer(FactoryPlayer factory) {
        this.factoryPlayer = factory;
    }

    public Player createPlayer(String type) {
        Player player;

        player = factoryPlayer.createSelectedPlayer(type);

        // inicjalizacja metod gracza z klasy Player
        // metoda 1
        // ...
        // metoda 2
        // ...
        // metoda 3
        // ...
        return player;
    }

    public void listenSocket(int portNumber){

        try
        {
            socket = new Socket("localhost", portNumber);
            System.out.println("Polaczono z serwerem");
//            out = new PrintWriter(socket.getOutputStream(), true);
//            in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        }
        catch (UnknownHostException e)
        {
            System.out.println("Unknown host: localhost"); System.exit(1);
        }
        catch  (IOException e)
        {
            System.out.println("Server isn't created");
            System.exit(1);
        }
    }

    final FactoryPlayer factoryPlayer;

    Socket socket;

}
